package com.lixiaoyi.ems.service.impl;

import com.lixiaoyi.ems.dao.IEmpManagerDao;
import com.lixiaoyi.ems.dao.impl.EmpManagerDaoImpl;
import com.lixiaoyi.ems.entity.EmpManager;
import com.lixiaoyi.ems.service.IEmpManagerService;
import com.lixiaoyi.ems.utils.DbUtils;

/**
 * @Author 李小毅
 * @Description
 * @Date 2022-05-18
 */

public class EmpManagerServiceImpl implements IEmpManagerService {

    private IEmpManagerDao empManagerDao =new EmpManagerDaoImpl();

    @Override
    public EmpManager login(String username, String password) {
        EmpManager empManager = null;
        try {
            DbUtils.begin();
            EmpManager temp = empManagerDao.select(username);
            if (temp != null){
                if (temp.getPassword().equals(password)){
                    empManager = temp;
                }
            }
            DbUtils.commit();
        } catch (Exception e) {
            DbUtils.rollback();
            e.printStackTrace();
        }
        return empManager;
    }
}
